package com.gduf.bbl.controller;

import java.util.Arrays;
import java.util.Map;

import com.gduf.bbl.common.utils.PageUtils;
import com.gduf.bbl.common.utils.R;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.gduf.bbl.entity.AreaEntity;
import com.gduf.bbl.service.AreaService;




/**
 * 
 *
 * @author xqw
 * @email 2041411595@qq.com
 * @date 2024-02-29 20:38:49
 */
@RestController
@RequestMapping("bbl/area")
@CrossOrigin(allowCredentials = "true")
public class AreaController {
    @Autowired
    private AreaService areaService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = areaService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("根据校区id获取校区信息")
    @ApiImplicitParam(type = "String",name = "areaId",value = "校区id",required = true)
    @GetMapping("/getAreaById")
    public R info(String areaId){
		AreaEntity area = areaService.getById(areaId);

        return R.ok().setData(area);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody AreaEntity area){
		areaService.save(area);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody AreaEntity area){
		areaService.updateById(area);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Integer[] aIds){
		areaService.removeByIds(Arrays.asList(aIds));

        return R.ok();
    }

}
